#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef pair<ll , ll> PII ;
typedef vector<bool> vb ;
typedef vector<ll> vi;
typedef vector<PII> vpi;
typedef vector<vector<ll>> vvi;
typedef vector<char> vc ;
const double EBS = 1e-9;
const double pi = 3.14159265358979 ;
#define Log(x) (31^__builtin_clz(x)) // Easily calculate log2 on GNU G++ compilers
#define logll(x) (63^__builtin_clzll(x))
#define popcount(i) __builtin_popcount(i)
#define mp make_pair
#define testCase ll t; cin >> t; while (t--)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(f, s, i) for (ll i = f; i < s; i++)
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
#define calunique(v) disance(v.begin(),unique(v.begin(),v.end()));
#define el cout << "\n"
#define mb make_pair
#define pb push_back
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define all(v) v.begin(), v.end()
#define INF (ll) 1e9
#define INFLL (ll)1e18
#define debug cout << "___________________________________" << endl
#define left ((p<<1) + 1)
#define right ((p<<1) + 2)
#define int ll
void solve(){
int a , b , x ; cin >> a >> b >> x ;
if(a < b) swap(a , b);
bool ok = 1 ;
for(int i = 59 ; i >= 0 ; i--){
int bit = (1LL << i) ;
if((a & bit) && !(b & bit)){
if(ok){
ok = 0 ;
continue ;
}
if(x < bit) continue ;
a ^= bit ;
b ^= bit ;
x -= bit ;
}
}
cout << abs(a - b) << endl ;
}
int32_t main(){
fast ;
testCase{
solve();
}
return 0;
}
742A - Arpa’s hard exam and Mehrdad’s naive cheat | 1492A - Three swimmers |
1360E - Polygon | 1517D - Explorer Space |
1230B - Ania and Minimizing | 1201A - Important Exam |
676A - Nicholas and Permutation | 431A - Black Square |
474B - Worms | 987B - High School Become Human |
1223A - CME | 1658B - Marin and Anti-coprime Permutation |
14B - Young Photographer | 143A - Help Vasilisa the Wise 2 |
320A - Magic Numbers | 1658A - Marin and Photoshoot |
514A - Chewbaсca and Number | 382A - Ksenia and Pan Scales |
734B - Anton and Digits | 1080A - Petya and Origami |
1642D - Repetitions Decoding | 1440A - Buy the String |
1658F - Juju and Binary String | 478A - Initial Bet |
981A - Antipalindrome | 365A - Good Number |
1204B - Mislove Has Lost an Array | 1409D - Decrease the Sum of Digits |
1476E - Pattern Matching | 1107A - Digits Sequence Dividing |